package com.bz.websocket.exception;

import com.bz.websocket.error.ErrorCode;

import org.springframework.core.NestedRuntimeException;

/**
 * @author zhongyongbin
 * @since 2021/5/10
 */
public class BizException extends NestedRuntimeException {

    private final ErrorCode errorCode;

    public BizException(ErrorCode errorCode) {
        super("Business error! Reason: " + errorCode.getMessage());
        this.errorCode = errorCode;
    }

    public BizException(ErrorCode errorCode, Exception e) {
        super("Business error! Reason: " + errorCode.getErrorCode(), e);
        this.errorCode = errorCode;
    }

    public ErrorCode getErrorCode() {
        return errorCode;
    }
}
